package com.goldgov.kduck.config;

import com.goldgov.kduck.locator.JdbcRouteLocator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.cloud.netflix.zuul.filters.ZuulProperties;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;


@Configuration
public class GatewayConfiguation {
    Logger log = LoggerFactory.getLogger(GatewayConfiguation.class);
//    @Autowired
//    private JdbcRouteLocator jdbcRouteLocator;
    @Bean
    public JdbcRouteLocator jdbcRouteLocator(ZuulProperties zuulProperties, ServerProperties serverProperties, JdbcTemplate jdbcTemplate, ApplicationEventPublisher publisher) {
        JdbcRouteLocator jdbcRouteLocator = new JdbcRouteLocator(serverProperties.getServlet().getContextPath(), zuulProperties, jdbcTemplate, publisher);
        log.info("JdbcRouteLocator:{}", jdbcRouteLocator);
        return jdbcRouteLocator;
    }
}
